package com.qiyue.admin.entity.base.dict;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.qiyue.admin.constant.AdminCommonConstant;
import com.qiyue.common.model.BaseEntity;
import io.swagger.annotations.ApiModelProperty;

import javax.persistence.*;
import java.util.List;

/**
 * created by yebinghuan on 2018/4/2
 *   数据字典类型实体类
 *
 */
@Entity
@Table( name = "sys_dict_type")
public class DictType extends BaseEntity{

    /**
     * 前台用该字段获取对应的数据字典数组
     */
    @ApiModelProperty(value = "字典标识")
    @Column(name = "code" ,length = 64)
    private  String code;

    /**
     *  用于标识返回类型
     */
    @ApiModelProperty( value = "字典类型")
    @Column( name = "type" )
    private int type;


    /**
     *  项名称
     */
    @ApiModelProperty( value = "字典名称")
    @Column( name = "name" ,length = 64)
    private String name;


    /**
     * 这是个树你懂的
     */
    @ApiModelProperty( value = "父级ID")
    @Column(name = "parent_id")
    private Long parentId = AdminCommonConstant.ROOT;


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    /**
     * 级联
     */


    private List<DictValue> dictValues;

    @OneToMany(cascade = CascadeType.ALL , fetch = FetchType.EAGER , mappedBy = "dictType")
    @JsonIgnore
    public List<DictValue> getDictValues() {
        return dictValues;
    }

    public void setDictValues(List<DictValue> dictValues) {
        this.dictValues = dictValues;
    }
}
